package libs.yzx.zaza;

import android.app.Application;
import android.content.ComponentName;
import android.content.Context;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.Parcel;
import android.util.Log;

import com.alipay.euler.andfix.patch.PatchManager;

import java.io.File;

/**
 * Created by Administrator on 2016/7/12
 */
public class AAA_Application extends Application {

    public static boolean DEBUG = true;
    private static PatchManager patchManager;
    public static AAA_Application app;

    public static class In {
        static int a;

        static {
            Log.e("------->>", "Application 里边的 static块执行");
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
        app = this;
        In.a = 9;

        try {
            patchManager = new PatchManager(this);
            String version_name = getPackageManager().getPackageInfo(getPackageName(),0).versionName;
            patchManager.init(version_name);
            patchManager.loadPatch();

            /* 生成补丁文件的命令 */
            //./apkpatch.sh -f fix.apk -t bug.apk -o ./ -k key.keystore -p 123456 -a alias -e 123456
            /* 补丁生成文件下载地址 */
            //https://github.com/alibaba/AndFix/raw/master/tools/apkpatch-1.0.3.zip

            /* 下边是测试补丁的代码 */
            /* 读取sd卡中的补丁文件 ，没问题的和有bug的都需要这一步 */
            File file = new File(getFilesDir(), "test.apatch");
            patchManager.addPatch(file.getAbsolutePath());

        }catch (Exception e){
            Log.e("------>>","err" , e);
        }

        //     Toast.makeText(AAA_Application.this, "Application Created", Toast.LENGTH_SHORT).show();


        new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName name, IBinder service) {
                Parcel obtain = Parcel.obtain();

            }

            @Override
            public void onServiceDisconnected(ComponentName name) {

            }
        };
    }


    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        //   Toast.makeText(base, "Application Created22222", Toast.LENGTH_SHORT).show();
    }

}
